﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using System.Data;
using System.Configuration;

namespace WaveMaster.Holidays.Club.Web.AspxPage
{
    public partial class ReportPrintDirectly : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string p = Request.QueryString["ReportFile"];
            string c = Request.QueryString["ReportDataSource"];
            if (p == null && c == null)
                return;
            string sessionReportFile = Session[Request.QueryString["ReportFile"]].ToString();
            DataSet sessionReportData = (DataSet)Session[Request.QueryString["ReportDataSource"]];
            if (sessionReportData != null)
            {
                string repPath = ConfigurationManager.AppSettings["ReportPath"] + sessionReportFile;
                DataSet dsRD = sessionReportData;
                ReportDocument rd = new ReportDocument();
                rd.Load(repPath);
                rd.SetDataSource(dsRD.Tables[0]);
                CrystalReportViewer.ReportSource = rd;
                CrystalReportViewer.DataBind();
                rd.PrintToPrinter(1, false, 1, 1);
            }
        }
    }
}